﻿//---------------------------------------------------------------------
// Author: Harley Green
//
// Description: Class to purge a MSMQueue
//
// Creation Date: 2008/3/8
//---------------------------------------------------------------------

using System.Management.Automation;

namespace Pscx.Commands.Messaging
{
    [Cmdlet(VerbsCommon.Clear, PscxNouns.MSMQueue,
        DefaultParameterSetName = "Named", SupportsShouldProcess = true)]
    public class ClearMSMQueue : MessageQueueCmdlet
    {
        protected override void ProcessRecord()
        {
            if (!Exists) return;
            if (!ShouldProcess(GetPath())) return;
            using (var messageQueue = GetQueue())
            {
                messageQueue.Purge();
            }
        }
    }
}